package cn.edu.sgu.www.mhxysy.dto.trade;

import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.RegExps;
import cn.edu.sgu.www.mhxysy.dto.DataTransferObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.time.LocalDate;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Data
@ApiModel
public class TradeRecordDTO implements DataTransferObject {

    @ApiModelProperty(value = "ID")
    private Integer id;

    /**
     * 交易价格
     */
    @Min(value = 1000, message = "交易价格不能低于1000")
    @NotNull(message = "交易价格" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "交易价格", required = true)
    private Integer price;

    /**
     * 角色ID
     */
    @Pattern(regexp = RegExps.ROLE_ID, message = "角色ID" + CustomMessages.ILLEGAL)
    @NotBlank(message = CustomMessages.ROLE_ID_NOT_NULL)
    @ApiModelProperty(value = "角色ID", required = true)
    private String roleId;

    /**
     * 数据编号
     */
    @NotBlank(message = "数据编号" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "数据编号", required = true)
    private String dataId;

    /**
     * 数据表名
     */
    @NotBlank(message = "数据表名" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "数据表名", required = true)
    private String tableName;

    /**
     * 交易类型
     */
    @Positive(message = "交易类型" + CustomMessages.ILLEGAL)
    @NotNull(message = "交易类型" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "交易类型", required = true)
    private Integer tradeType;

    /**
     * 是否跨服
     */
    @Positive(message = "是否跨服" + CustomMessages.ILLEGAL)
    @NotNull(message = "是否跨服" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "是否跨服", required = true)
    private Integer crossSever;

    /**
     * 是否指定
     */
    @Positive(message = "是否指定" + CustomMessages.ILLEGAL)
    @NotNull(message = "是否指定" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "是否指定", required = true)
    private Integer designated;

    /**
     * 交易时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Past(message = "交易时间" + CustomMessages.ILLEGAL)
    @NotNull(message = "交易时间" + CustomMessages.NOT_NULL)
    @ApiModelProperty(value = "交易时间", required = true)
    private LocalDate tradeTime;
}